﻿<Window x:Class="DBLint.DBLintGui.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:DBLint.DBLintGui"
        Title="DBLint V8"
        Height="500"
        Width="800" Closed="Window_Closed">
    <DockPanel>
        <Button IsEnabled="{Binding ElementName=tabControl, Path=SelectedValue.Content.ValidState}"
                Name="nextButton"
                DockPanel.Dock="Bottom">
            <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="Content"
                            Value="_Next" />
                    <EventSetter Event="Click"
                                 Handler="nextButton_Click" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=executeViewer, Path=IsVisible}"
                                     Value="True">
                            <Setter Property="Content"
                                    Value="_Execute" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>

        <TabControl Name="tabControl"
                    Uid="tabControl">

            <TabItem Header="Table Selection">
                <local:ValidStateUserControl x:Name="startupScreen">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="146" />
                            <ColumnDefinition Width="622" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="10" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <local:SelectConnection  x:Name="SelectConnection"
                                                 DataContext="{Binding}"
                                                 ConnectionChanged="SelectConnection_ConnectionChanged" Grid.ColumnSpan="2" />
                        <GridSplitter Grid.Row="1"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Center"
                                      Height="5" Grid.ColumnSpan="2" Margin="0,2" />
                        <local:PerformSelection Grid.Row="2"
                                                x:Name="performSelection"
                                                IsEnabled="{Binding ElementName=SelectConnection, Path=ValidState}"
                                                ValidStateChanged="performSelection_ValidStateChanged" Grid.ColumnSpan="2" />
                    </Grid>
                </local:ValidStateUserControl>
            </TabItem>

            <TabItem Header="Rule Configuration"
                     IsEnabled="{Binding ElementName=performSelection, Path=ValidState}">
                <local:SelectRules x:Name="selectRules"
                                   IsVisibleChanged="selectRules_IsVisibleChanged" Loaded="selectRules_Loaded" />
            </TabItem>

            <TabItem Header="Execute">
                <TabItem.Style>
                    <Style TargetType="{x:Type TabItem}">
                        <Setter Property="IsEnabled"
                                Value="False" />
                        <Style.Triggers>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding ElementName=selectRules,Path=ValidState}"
                                               Value="True" />
                                    <Condition Binding="{Binding ElementName=performSelection,Path=ValidState}"
                                               Value="True" />
                                </MultiDataTrigger.Conditions>
                                <Setter Property="IsEnabled"
                                        Value="True" />
                            </MultiDataTrigger>
                        </Style.Triggers>
                    </Style>
                </TabItem.Style>
                <local:ExecuteDBLint  x:Name="executeViewer"
                                      IsVisibleChanged="executeViewer_IsVisibleChanged" />
            </TabItem>

        </TabControl>
    </DockPanel>
</Window>
